package csdn_2;

import java.io.FileWriter;
import java.io.IOException;

public class Test1 {
    public static void main(String[] args) {
        String path="D:\\javacode\\javacode\\IO_1\\write.txt";//写入路径
        String str="今天是2025年，祝大家新年快乐！";//写入内容
        FileWriter fileWriter=null;

        try {
            fileWriter = new FileWriter(path);//默认是覆盖写入
            fileWriter.write(str);


        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            try {
                if(fileWriter!=null) {
                    fileWriter.close();
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
